package com.sdsmusic.Song;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.sdsmusic.controller.Controller;

public class TempStoreController implements Controller{

	@Override
	public String handleRequest(HttpServletRequest request) {
		HttpSession session = request.getSession();
		
		int nMaxSong = (Integer)session.getAttribute("nMaxSong");
		
		int alb_id = (Integer)session.getAttribute("album_id");
		String temp = null;
		ArrayList<SongVO> songList = new ArrayList<SongVO>();
		for(int i=0;i<nMaxSong;i++){
			SongVO song = new SongVO();
			temp = request.getParameter("track_"+i);
			if(temp == null || temp.equals(""))
				break; 			
			song.setTrack_num(Integer.parseInt(temp));
			song.setAlbId(alb_id);
			temp = request.getParameter("title_"+i);
			song.setTitle(temp);
			temp = request.getParameter("singer_"+i);
			song.setSinger(temp);
			temp = request.getParameter("composer_"+i);
			song.setComposer(temp);
			temp = request.getParameter("lyric_"+i);
			song.setLyricist(temp);
			songList.add(song);
		}		
//		session.setAttribute("tempSongList", songList);
		session.setAttribute("nMaxSong", nMaxSong+1);
		return  "./newSong.jsp";
	}

}
